var util = require('../../utils/util.js')
var app = getApp();
var md5 = require('../md5.js');
Page({
  data: {
    sfdl: '1',
    currentTab: 0,
    showModal: false,
    luzsshow: false,
    "bnrUrl": [{
      "url": "../../images/2.jpg"
    }, {
      "url": "../../images/2.jpg"
    }, {
      "url": "../../images/2.jpg"
    }],
    showLeftMenu: false,
  },
  submit: function () {
    this.setData({
      showModal: true
    })
  },
  onPullDownRefresh: function () {
    wx.stopPullDownRefresh({
      complete: (res) => {},
    });
  },
  //底部导航跳转
  toAiIndex: function () {
    util.toAiIndex()
  },
  toContactsIng: function () {
    util.toContactsIng()
  },
  toProductRevision: function () {
    util.toProductRevision()
  },
  toMy: function () {
    util.toMy()
  },
  toBadge: function () {
    util.toBadge()
  },
  toSign: function () {
    wx.navigateTo({
      url: '../signInbyPhone/signIn'
    })
  },
  toChangeShow: function () {
    var that = this
    that.setData({
      luzsshow: false
    })
  },
  uploadPhoto(e) { // 拍摄或从相册选取上传
    let that = this;
    wx.chooseImage({
      count: 1, // 默认9
      sizeType: ['compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: function (res) {
        console.log("base64=" + wx.getFileSystemManager().readFileSync(res.tempFilePaths[0], "base64"))
        var base64img = wx.getFileSystemManager().readFileSync(res.tempFilePaths[0], "base64") + ''
        //上传头像
        var exhibitionid = wx.getStorageSync('exhibitionid')
        var u = wx.getStorageSync('u')
        if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid')) &&
          (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
          //默认最新（调用pico接口）
          var timestamp = Date.parse(new Date());
          timestamp = timestamp / 1000;
          var url = app.globalData.picoaddress + '/attendee/user/uploadphoto'
          var k = {}
          k["v"] = '1.0.0'
          k["client"] = 'ios'
          k["timestamp"] = timestamp
          k["lan"] = 'cn'
          k["exhibitionid"] = exhibitionid
          k["u"] = u
          k["base64img"] = base64img
          var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
          console.log(sign)
          var curb64 = md5.hexMD5(sign)
          console.log(curb64)
          k["sign"] = curb64
          wx.request({
            header: {
              'content-type': 'application/x-www-form-urlencoded',
            },
            url: url,
            method: 'post',
            data: k,
            success(res) {
              var exhibitionid = wx.getStorageSync('exhibitionid')
              var u = wx.getStorageSync('u')
              console.log('exhibitionid=' + exhibitionid)
              console.log('u=' + u)
              if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid')) &&
                (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
                //默认最新（调用pico接口）
                var timestamp = Date.parse(new Date());
                timestamp = timestamp / 1000;
                var k = {}
                k["v"] = '1.0.0'
                k["client"] = 'ios'
                k["timestamp"] = timestamp
                k["lan"] = 'cn'
                k["exhibitionid"] = exhibitionid
                k["u"] = u
                var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
                console.log(sign)
                var curb64 = md5.hexMD5(sign)
                console.log(curb64)
                k["sign"] = curb64
                //重新获取头像
                var url = app.globalData.picoaddress + '/Attendee/user/getdeviceid'
                wx.request({
                  header: {
                    'content-type': 'application/x-www-form-urlencoded',
                  },
                  url: url,
                  method: 'post',
                  data: k,
                  success(res) {
                    console.log(res)
                    var mesg = res.data
                    console.log('mesg=' + mesg)
                    var curdata = mesg.data
                    that.setData({
                      grMesg: curdata
                    });
                  },
                  fail: res => {
                    console.log(res, "error")
                  }

                })
              }
            },
            fail: res => {
              console.log(res, "error")
            }
          })
        }


      },
    })

  },
  hiddenAction: function () {
    this.setData({
      showLeftMenu: false,
    });
  },
  showAction: function () {
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    if (exhibitionid == '0' && u == '0') {
      wx.navigateTo({
        url: '../signInbyPhone/signIn'
      })
    } else {
      this.setData({
        showLeftMenu: true,
      });
    }

  },
  tozsDetail: function (e) {
    var id = e.currentTarget.dataset.zsid
    wx.navigateTo({
      url: '../exhibitorModule/exhibitorsIntroduciton?exhibitorid=' + id,
    })

  },
  toScanning: function () {
    wx.reLaunch({
      url: '../scanning/scanning'
    })

  },
  tocpDetail: function (e) {
    var id = e.currentTarget.dataset.cpid
    wx.navigateTo({
      url: '../productModule/productDetails?productid=' + id,
    })
  },
  toyjDetail: function (e) {
    var id = e.currentTarget.dataset.yjid
    wx.navigateTo({
      url: '../speechModule/speakerDetails?speakerid=' + id,
    })
  },

  preventTouchMove: function () {

  },
  go: function (e) {
    var that = this;
    var kk = that.data.currentTab
    console.log("curtab=", kk)
    //获取关键词
    var keyword = e.detail.value
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    console.log('exhibitionid=' + exhibitionid)
    console.log('u=' + u)
    if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid')) &&
      (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
      //默认最新（调用pico接口）
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = ''
      var k = {}
      var sign = ''
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["u"] = u
      if (keyword || !"".trim() == keyword) {
        k["keyword"] = keyword
        url = app.globalData.picoaddress + '/attendee/indexpage/search'
        sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'keyword' + keyword + 'timestamp' + timestamp + app.globalData.picotoken
      } else {
        url = app.globalData.picoaddress + '/attendee/indexpage/recommendsall'
        sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      }

      console.log(sign)
      var curb64 = md5.zhMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            tjMesg: curdata
          });
        },
        fail: res => {
          console.log(res, "error")
        }

      })
    } else {
      wx.redirectTo({
        url: '../signInbyPhone/signIn'
      })
    }
  },
  sendMesg: function (e) {
    var mesg = e.detail.value
    var that = this;
    //设置语言0:中文，1：英文
    var setlanguage = wx.getStorageSync('setlanguage')
    if ((wx.getStorageSync('setlanguage') || !"".trim() == wx.getStorageSync('setlanguage'))) {
      this.setData({
        setlanguage: wx.getStorageSync('setlanguage')
      })
    } else {
      wx.setStorageSync('setlanguage', 0);
      this.setData({
        setlanguage: 0
      })
    }
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid')) &&
      (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {

      wx.navigateTo({
        url: '../searchIng/searchIng?keyword=' + mesg,
      })
    } else {
      wx.redirectTo({
        url: '../signInbyPhone/signIn'
      })
    }
  },

  onLoad: function (options) {
    var that = this;
    // 页面初始化 options为页面跳转所带来的参数 
    //获取缓存展会id和用户id存在则获取最新联系人列表
    //设置语言0:中文，1：英文
    var setlanguage = wx.getStorageSync('setlanguage')
    console.log('setlanguage=' + setlanguage)
    if (wx.getStorageSync('setlanguage') || !("".trim() == wx.getStorageSync('setlanguage'))) {
      this.setData({
        setlanguage: wx.getStorageSync('setlanguage')
      })
      console.log('bbbbbbbbbbbbbbbbbbbbbbbb')
      if (setlanguage == 1) {
        wx.setNavigationBarTitle({
          title: 'home page'
        })
      } else {
        wx.setNavigationBarTitle({
          title: '首页'
        })
      }
    } else {
      //  console.log('cccccccccccccccccc')
      wx.setStorageSync('setlanguage', 0);
      this.setData({
        setlanguage: 0
      })
    }
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    if (!((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid')) &&
        (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u')))) {
      console.log("nnnnnnnnnnnnnnnn")
      wx.setStorageSync('exhibitionid', '0');
      wx.setStorageSync('u', '0');
      that.setData({
        sfdl: '0'
      })
    }
    if (exhibitionid == '0' && u == '0') {
      console.log("gggggggggggggggg")
      that.setData({
        sfdl: '0'
      })
    }
    // console.log('exhibitionid=' + exhibitionid)
    // console.log('u=' + u)
    if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid')) &&
      (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
      //默认最新（调用pico接口）
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = app.globalData.picoaddress + '/attendee/indexpage/recommendsall'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["u"] = u

      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            tjMesg: curdata
          });
        },
        fail: res => {
          console.log(res, "error")
        }

      })

      //获取头像
      var url1 = app.globalData.picoaddress + '/Attendee/user/getdeviceid'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url1,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            grMesg: curdata
          });
        },
        fail: res => {
          console.log(res, "error")
        }

      })
      //获取站内消息数
      var url2 = app.globalData.picoaddress + '/attendee/sysmessage/getnoread'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url2,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          console.log('mesgCount=' + curdata.noreadtotal)
          that.setData({
            mesgCount: curdata.noreadtotal
          })

        },
        fail: res => {
          console.log(res, "error")
        }

      })

      //获取曝光率
      var url3 = app.globalData.picoaddress + '/attendee/indexpage/getpv'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url3,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            pv: curdata.pv
          })

        },
        fail: res => {
          console.log(res, "error")
        }

      })
      //页面banner
      var url4 = app.globalData.picoaddress + '/Attendee/indexpage/scrollingbanner'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url4,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            lburl: curdata
          })

        },
        fail: res => {
          console.log(res, "error")
        }

      })

      //页面展商banner
      var m = {}
      m["v"] = '1.0.0'
      m["client"] = 'ios'
      m["timestamp"] = timestamp
      m["lan"] = 'cn'
      m["exhibitionid"] = exhibitionid
      m["adtype"] = 0
      m["u"] = u
      var sign = app.globalData.picotoken + 'adtype0clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      m["sign"] = curb64
      var url5 = app.globalData.picoaddress + '/attendee/indexpage/exhibitionbanner'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url5,
        method: 'post',
        data: m,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            indexzslburl: curdata.banner
          })

        },
        fail: res => {
          console.log(res, "error")
        }

      })
      //页面产品banner
      var m = {}
      m["v"] = '1.0.0'
      m["client"] = 'ios'
      m["timestamp"] = timestamp
      m["lan"] = 'cn'
      m["exhibitionid"] = exhibitionid
      m["adtype"] = 1
      m["u"] = u
      var sign = app.globalData.picotoken + 'adtype1clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      m["sign"] = curb64
      var url6 = app.globalData.picoaddress + '/attendee/indexpage/exhibitionbanner'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url6,
        method: 'post',
        data: m,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            indexcplburl: curdata.banner
          })

        },
        fail: res => {
          console.log(res, "error")
        }

      })
      //页面演讲banner
      var m = {}
      m["v"] = '1.0.0'
      m["client"] = 'ios'
      m["timestamp"] = timestamp
      m["lan"] = 'cn'
      m["exhibitionid"] = exhibitionid
      m["adtype"] = 2
      m["u"] = u
      var sign = app.globalData.picotoken + 'adtype2clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      m["sign"] = curb64
      var url7 = app.globalData.picoaddress + '/attendee/indexpage/exhibitionbanner'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url7,
        method: 'post',
        data: m,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            indexyjlburl: curdata.banner
          })

        },
        fail: res => {
          console.log(res, "error")
        }

      })
     
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var cururl = app.globalData.picoaddress + '/attendee/user/setrecommend'
      var state='0'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["u"] = u
      k["state"] = state
      k["opstate"] = '1'
      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'opstate1' + 'state' + state + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: cururl,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
        }, fail: res => {
          console.log(res, "error")
        }

      })
    } else {
      wx.redirectTo({
        url: '../signInbyPhone/signIn'
      })
    }

  },
  onShow: function () {
    var that = this;
    // 页面初始化 options为页面跳转所带来的参数 
    //获取缓存展会id和用户id存在则获取最新联系人列表
    //设置语言0:中文，1：英文
    var setlanguage = wx.getStorageSync('setlanguage')
    console.log('setlanguage=' + setlanguage)
    if (wx.getStorageSync('setlanguage') || !("".trim() == wx.getStorageSync('setlanguage'))) {
      this.setData({
        setlanguage: wx.getStorageSync('setlanguage')
      })
      console.log('bbbbbbbbbbbbbbbbbbbbbbbb')
      if (setlanguage == 1) {
        wx.setNavigationBarTitle({
          title: 'home page'
        })
      } else {
        wx.setNavigationBarTitle({
          title: '首页'
        })
      }
    } else {
      console.log('ccccccccccccccccccbbb')
      wx.setStorageSync('setlanguage', 0);
      this.setData({
        setlanguage: 0
      })
    }
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    console.log('exhibitionid=' + exhibitionid)
    console.log('u=' + u)
    if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid')) &&
      (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
      //默认最新（调用pico接口）
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = app.globalData.picoaddress + '/attendee/indexpage/recommendsall'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["u"] = u

      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            tjMesg: curdata
          });
        },
        fail: res => {
          console.log(res, "error")
        }

      })

      //获取头像
      var url1 = app.globalData.picoaddress + '/Attendee/user/getdeviceid'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url1,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            grMesg: curdata
          });
        },
        fail: res => {
          console.log(res, "error")
        }

      })
      //获取站内消息数
      var url2 = app.globalData.picoaddress + '/attendee/sysmessage/getnoread'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url2,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          console.log('mesgCount=' + curdata.noreadtotal)
          that.setData({
            mesgCount: curdata.noreadtotal
          })

        },
        fail: res => {
          console.log(res, "error")
        }

      })

      //获取曝光率
      var url3 = app.globalData.picoaddress + '/attendee/indexpage/getpv'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url3,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            pv: curdata.pv
          })

        },
        fail: res => {
          console.log(res, "error")
        }

      })
      //页面banner
      var url4 = app.globalData.picoaddress + '/Attendee/indexpage/scrollingbanner'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url4,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            lburl: curdata
          })

        },
        fail: res => {
          console.log(res, "error")
        }

      })

       //页面展商banner
       var m = {}
       m["v"] = '1.0.0'
       m["client"] = 'ios'
       m["timestamp"] = timestamp
       m["lan"] = 'cn'
       m["exhibitionid"] = exhibitionid
       m["adtype"] = 0
       m["u"] = u
       var sign = app.globalData.picotoken + 'adtype0clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
       console.log(sign)
       var curb64 = md5.hexMD5(sign)
       console.log(curb64)
       m["sign"] = curb64
       var url5 = app.globalData.picoaddress + '/attendee/indexpage/exhibitionbanner'
       wx.request({
         header: {
           'content-type': 'application/x-www-form-urlencoded',
         },
         url: url5,
         method: 'post',
         data: m,
         success(res) {
           console.log(res)
           var mesg = res.data
           console.log('mesg=' + mesg)
           var curdata = mesg.data
           that.setData({
             indexzslburl: curdata.banner
           })
 
         },
         fail: res => {
           console.log(res, "error")
         }
 
       })
       //页面产品banner
       var m = {}
       m["v"] = '1.0.0'
       m["client"] = 'ios'
       m["timestamp"] = timestamp
       m["lan"] = 'cn'
       m["exhibitionid"] = exhibitionid
       m["adtype"] = 1
       m["u"] = u
       var sign = app.globalData.picotoken + 'adtype1clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
       console.log(sign)
       var curb64 = md5.hexMD5(sign)
       console.log(curb64)
       m["sign"] = curb64
       var url6 = app.globalData.picoaddress + '/attendee/indexpage/exhibitionbanner'
       wx.request({
         header: {
           'content-type': 'application/x-www-form-urlencoded',
         },
         url: url6,
         method: 'post',
         data: m,
         success(res) {
           console.log(res)
           var mesg = res.data
           console.log('mesg=' + mesg)
           var curdata = mesg.data
           that.setData({
             indexcplburl: curdata.banner
           })
 
         },
         fail: res => {
           console.log(res, "error")
         }
 
       })
       //页面演讲banner
       var m = {}
       m["v"] = '1.0.0'
       m["client"] = 'ios'
       m["timestamp"] = timestamp
       m["lan"] = 'cn'
       m["exhibitionid"] = exhibitionid
       m["adtype"] = 2
       m["u"] = u
       var sign = app.globalData.picotoken + 'adtype2clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
       console.log(sign)
       var curb64 = md5.hexMD5(sign)
       console.log(curb64)
       m["sign"] = curb64
       var url7 = app.globalData.picoaddress + '/attendee/indexpage/exhibitionbanner'
       wx.request({
         header: {
           'content-type': 'application/x-www-form-urlencoded',
         },
         url: url7,
         method: 'post',
         data: m,
         success(res) {
           console.log(res)
           var mesg = res.data
           console.log('mesg=' + mesg)
           var curdata = mesg.data
           that.setData({
             indexyjlburl: curdata.banner
           })
 
         },
         fail: res => {
           console.log(res, "error")
         }
 
       })
    } else {
      wx.redirectTo({
        url: '../signInbyPhone/signIn'
      })
    }

  },
  sc: function (e) {
    var that = this
    var speakerid = e.currentTarget.dataset.tagid
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    console.log('exhibitionid=' + exhibitionid)
    console.log('u=' + u)
    if (!(exhibitionid == '0' && u == '0')) {
      //默认最新（调用pico接口）
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = app.globalData.picoaddress + '/attendee/speakers/collect'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["speakerid"] = speakerid
      k["u"] = u
      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'speakerid' + speakerid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          //从新加载数据刷新
          if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid')) &&
            (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
            //默认最新（调用pico接口）
            var timestamp = Date.parse(new Date());
            timestamp = timestamp / 1000;
            var url = app.globalData.picoaddress + '/attendee/indexpage/recommendsall'
            var k = {}
            k["v"] = '1.0.0'
            k["client"] = 'ios'
            k["timestamp"] = timestamp
            k["lan"] = 'cn'
            k["exhibitionid"] = exhibitionid
            k["u"] = u

            var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
            console.log(sign)
            var curb64 = md5.hexMD5(sign)
            console.log(curb64)
            k["sign"] = curb64
            wx.request({
              header: {
                'content-type': 'application/x-www-form-urlencoded',
              },
              url: url,
              method: 'post',
              data: k,
              success(res) {
                console.log(res)
                var mesg = res.data
                console.log('mesg=' + mesg)
                var curdata = mesg.data
                that.setData({
                  tjMesg: curdata
                });
              },
              fail: res => {
                console.log(res, "error")
              }

            })

            //获取头像
            var url1 = app.globalData.picoaddress + '/Attendee/user/getdeviceid'
            wx.request({
              header: {
                'content-type': 'application/x-www-form-urlencoded',
              },
              url: url1,
              method: 'post',
              data: k,
              success(res) {
                console.log(res)
                var mesg = res.data
                console.log('mesg=' + mesg)
                var curdata = mesg.data
                that.setData({
                  grMesg: curdata
                });
              },
              fail: res => {
                console.log(res, "error")
              }

            })
            //获取站内消息数
            var url2 = app.globalData.picoaddress + '/attendee/sysmessage/getnoread'
            wx.request({
              header: {
                'content-type': 'application/x-www-form-urlencoded',
              },
              url: url2,
              method: 'post',
              data: k,
              success(res) {
                console.log(res)
                var mesg = res.data
                console.log('mesg=' + mesg)
                var curdata = mesg.data
                console.log('mesgCount=' + curdata.noreadtotal)
                that.setData({
                  mesgCount: curdata.noreadtotal
                })

              },
              fail: res => {
                console.log(res, "error")
              }

            })

            //获取曝光率
            var url3 = app.globalData.picoaddress + '/attendee/indexpage/getpv'
            wx.request({
              header: {
                'content-type': 'application/x-www-form-urlencoded',
              },
              url: url3,
              method: 'post',
              data: k,
              success(res) {
                console.log(res)
                var mesg = res.data
                console.log('mesg=' + mesg)
                var curdata = mesg.data
                that.setData({
                  pv: curdata.pv
                })

              },
              fail: res => {
                console.log(res, "error")
              }

            })
            //页面banner
            var url4 = app.globalData.picoaddress + '/Attendee/indexpage/scrollingbanner'
            wx.request({
              header: {
                'content-type': 'application/x-www-form-urlencoded',
              },
              url: url4,
              method: 'post',
              data: k,
              success(res) {
                console.log(res)
                var mesg = res.data
                console.log('mesg=' + mesg)
                var curdata = mesg.data
                that.setData({
                  lburl: curdata
                })

              },
              fail: res => {
                console.log(res, "error")
              }

            })

             //页面展商banner
      var m = {}
      m["v"] = '1.0.0'
      m["client"] = 'ios'
      m["timestamp"] = timestamp
      m["lan"] = 'cn'
      m["exhibitionid"] = exhibitionid
      m["adtype"] = 0
      m["u"] = u
      var sign = app.globalData.picotoken + 'adtype0clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      m["sign"] = curb64
      var url5 = app.globalData.picoaddress + '/attendee/indexpage/exhibitionbanner'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url5,
        method: 'post',
        data: m,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            indexzslburl: curdata.banner
          })

        },
        fail: res => {
          console.log(res, "error")
        }

      })
      //页面产品banner
      var m = {}
      m["v"] = '1.0.0'
      m["client"] = 'ios'
      m["timestamp"] = timestamp
      m["lan"] = 'cn'
      m["exhibitionid"] = exhibitionid
      m["adtype"] = 1
      m["u"] = u
      var sign = app.globalData.picotoken + 'adtype1clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      m["sign"] = curb64
      var url6 = app.globalData.picoaddress + '/attendee/indexpage/exhibitionbanner'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url6,
        method: 'post',
        data: m,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            indexcplburl: curdata.banner
          })

        },
        fail: res => {
          console.log(res, "error")
        }

      })
      //页面演讲banner
      var m = {}
      m["v"] = '1.0.0'
      m["client"] = 'ios'
      m["timestamp"] = timestamp
      m["lan"] = 'cn'
      m["exhibitionid"] = exhibitionid
      m["adtype"] = 2
      m["u"] = u
      var sign = app.globalData.picotoken + 'adtype2clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      m["sign"] = curb64
      var url7 = app.globalData.picoaddress + '/attendee/indexpage/exhibitionbanner'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url7,
        method: 'post',
        data: m,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          that.setData({
            indexyjlburl: curdata.banner
          })

        },
        fail: res => {
          console.log(res, "error")
        }

      })
          }
        },
        fail: res => {
          console.log(res, "error")
        }
      })
    } else {
      wx.navigateTo({
        url: '../signInbyPhone/signIn'
      })
    }
  },
  //滑动切换
  swiperTab: function (e) {
    var that = this;
    that.setData({
      currentTab: e.detail.current
    });
  },
  setting: function () {
    wx.navigateTo({
      url: '../setupModule/setUp',
    });
    // this.hiddenAction();
  },
  toMesg: function () {
    wx.navigateTo({
      url: '../messageModule/notification',
    });
    // this.hiddenAction();
  },
  onShareAppMessage: function () {
    return {
      title: '2020西安五一云车展',
      imageUrl: 'pages/aiIndex/aiIndex'
    }
  },
  clickmore: function (e) {
    var that = this;
    var kk = that.data.currentTab
    console.log("curtab=", kk)
    if (kk == '0') {
      wx.navigateTo({
        url: '../exhibitorModule/exhibitorList'
      })
    }
    if (kk == '1') {
      wx.navigateTo({
        url: '../productModule/productList'
      })
    }
    if (kk == '2') {
      wx.navigateTo({
        url: '../speechModule/speaker'
      })
    }

  },
  luzs: function (e) {
    var that = this;
    //获取缓存展会id和用户id存在则获取最新联系人列表
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var toid = e.currentTarget.dataset.contactid
    var u = wx.getStorageSync('u')
    if (!(exhibitionid == '0' && u == '0')) {
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = app.globalData.picoaddress + '/attendee/exhibitors/contactme'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["toid"] = toid
      k["u"] = u

      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + 'toid' + toid + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          if (mesg.code == 200) {
            that.setData({
              luzsshow: true
            })    
          } else {
            wx.showToast({
              title: mesg.message,
              icon: 'none',
              duration: 1500
            })
          }

        },
        fail: res => {
          console.log(res, "error")
        }

      })
      
    } else {
      wx.navigateTo({
        url: '../signInbyPhone/signIn'
      })
    }
  },
  hqmp: function (e) {
    var that = this;
    var curid = e.currentTarget.dataset.tagid+''
    //获取缓存展会id和用户id存在则获取最新联系人列表
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var exhibitorid = (curid.split('-'))[0]
    var toid = (curid.split('-'))[1]
    var u = wx.getStorageSync('u')
    console.log('exhibitionid=' + exhibitionid)
    console.log('u=' + u)
    if (!(exhibitionid == '0' && u == '0')) {
      //默认最新（调用pico接口）
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = app.globalData.picoaddress + '/attendee/exhibitors/getexhibitorcard'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["exhibitorid"] = exhibitorid
      k["u"] = u

      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'exhibitorid' + exhibitorid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          if (mesg.code == 200) {
            wx.showToast({
              title: '展商名片成功添加到通讯录',
              icon: 'none',
              duration: 1500
            })
            wx.navigateTo({
              url: '../pageDetail/pageDetails?attendeeid=' + toid,
            })

          } else {
            wx.showToast({
              title: mesg.message,
              icon: 'none',
              duration: 1500
            })
          }
        },
        fail: res => {
          console.log(res, "error")
        }

      })


    } else {
      wx.navigateTo({
        url: '../signInbyPhone/signIn'
      })
    }
  },
  yjzs: function (e) {
    var that = this;
    //获取缓存展会id和用户id存在则获取最新联系人列表
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var toid = e.currentTarget.dataset.contactid
    //  var toid = that.data.toid
    // var fullname = that.data.fullname
    var u = wx.getStorageSync('u')
    console.log('exhibitionid=' + exhibitionid)
    console.log('u=' + u)
    if (!(exhibitionid == '0' && u == '0')) {
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      //==============加载联系人fullname=========================
      var cururl = app.globalData.picoaddress + '/attendee/contacts/detail'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["attendeeid"] = toid
      k["u"] = u
      var sign = app.globalData.picotoken + 'attendeeid' + toid + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: cururl,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          var fullname = curdata.fullname
          var url = app.globalData.picoaddress + '/attendee/exhibitors/appointment'
          var k = {}
          k["v"] = '1.0.0'
          k["client"] = 'ios'
          k["timestamp"] = timestamp
          k["lan"] = 'cn'
          k["exhibitionid"] = exhibitionid
          k["toid"] = toid
          k["u"] = u

          var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + 'toid' + toid + app.globalData.picotoken
          console.log(sign)
          var curb64 = md5.hexMD5(sign)
          console.log(curb64)
          k["sign"] = curb64
          wx.request({
            header: {
              'content-type': 'application/x-www-form-urlencoded',
            },
            url: url,
            method: 'post',
            data: k,
            success(res) {
              console.log(res)
              var mesg = res.data
              console.log('mesg=' + mesg)
              if (mesg.code == 200) {
                wx.showToast({
                  title: '约见展商消息已成功发出，等待展商确认',
                  icon: 'none',
                  duration: 2000
                })
                wx.navigateTo({
                  url: '../contactsModule/chat?attendeeid=' + toid + '&nickname=' + fullname,
                })

              } else {
                wx.showToast({
                  title: mesg.message,
                  icon: 'none',
                  duration: 2000
                })
              }
            },
            fail: res => {
              console.log(res, "error")
            }

          })

        },
        fail: res => {
          console.log(res, "error")
        }
      })

    } else {
      wx.navigateTo({
        url: '../signInbyPhone/signIn'
      })
    }
  },
  //点击切换
  clickTab: function (e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
  }
})